package com.dormitory.controller;

import com.dormitory.bean.FileBean;
import com.dormitory.httpHelper.HttpFile;

import org.json.JSONException;

import java.io.File;
import java.io.IOException;
import java.util.List;

/**
 * Created by JHF on 2017/10/20.
 */

public class FileController {
    private static FileController _fileController;
    public static FileController getInstance() {
        if(_fileController == null) {
            _fileController = new FileController();
        }
        return _fileController;
    }

    public boolean uploadFile(File file, String userName, int dormitoryId, boolean isSharing) {
        try {
            HttpFile.uploadFile(file, userName, dormitoryId, isSharing);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
    public List<List<FileBean>> getFileList(int dormitoryId) {
        try {
            return HttpFile.getFileList(dormitoryId);
        } catch (IOException e) {
            e.printStackTrace();
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return null;
    }
}
